<% layout('/layouts/default.html', {title: '菜单管理', libs: ['validate']}){ %>
<div class="card bd-0">
    <div class="card-header d-flex align-items-start justify-content-between box-header fixed">
        <div class="pt-1">${menu.isNewRecord ? '新增菜单' : '编辑菜单'}</div>
        <div class="d-flex">

        </div>
    </div>
    <#form:form id="inputForm" model="${menu}" action="${ctx}/sys/menu/save" method="post">
    	<#form:hidden path="menuCode" />
        <div class="card-body pd-sm-t-30 pd-sm-b-40 pd-sm-x-30">
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="parentCode">上级菜单</label>
                    <#form:treeselect 
                        id="parent" 
                        title="上级菜单"
						path="parent.menuCode"
						labelPath="parent.menuName"
						url="${ctx}/sys/menu/treeData?excludeCode="
						class="form-control"
						allowClear="true" 
						canSelectRoot="true" 
						canSelectParent="true"
                        />
                </div>
                <div class="form-group col-md-6">
                    <label for="menuType">菜单类型</label>
                    <div class="radio-list d-flex pd-t-5">
	                    <#form:radio path="menuType" dictType="sys_menu_type" value="${menu.menuType}"  defaultValue="1"/>
	                </div>
                </div>
            </div>
            <div class="form-row">
	            <div class="form-group  col-md-6">
	                <label>菜单名称</label>
	                <#form:input path="menuName" class="form-control required" placeholder="请输入菜单名称" />
	            </div>
	            <div class="form-group  col-md-6">
	                <label>菜单排序</label>
	                <#form:input path="treeSort" class="form-control required" placeholder="请输入菜单排序" />
	            </div>
            </div>
            <div class="form-row">
	            <div class="form-group  col-md-6">
	                <label>菜单连接</label>
	                <#form:input path="menuHref" class="form-control" placeholder="请输入菜单连接" />
	            </div>
	            <div class="form-group  col-md-6">
	                <label>权限标识</label>
	                <#form:input path="permission" class="form-control" placeholder="请输入权限标识" />
	            </div>
            </div>
            <div class="form-row">
	            <div class="form-group  col-md-6">
	                <label>菜单图标</label>
	                <div class="input-group">
	                	<#form:iconselect  path="menuIcon" class="form-control" placeholder="请输入菜单图标"  />
					</div>
	            </div>
	            <div class="form-group  col-md-6">
	                <label>目标地址</label>
	                <#form:input path="menuTarget" class="form-control" placeholder="请输入目标地址" />
	            </div>
            </div>
            <div class="form-row">
	            <div class="form-group  col-md-6">
	                <label>菜单权重</label>
	                <#form:select path="weight" dictType="sys_menu_weight" class="form-control select2 select2-no-search" />
	            </div>
	            <div class="form-group  col-md-6">
	                <label>是否可见</label>
	                <div class="radio-list d-flex pd-t-5">
	                <#form:radio path="isShow" dictType="sys_yes_no" class="required" defaultValue="1"/>
	                </div>
	            </div>
            </div>
            <div class="form-group">
                <label>备注</label>
                 <#form:textarea path="remarks" class="form-control" row="5" placeholder="请输入" />
            </div>
            
        </div>
        <div class="card-footer pd-sm-l-30">
            <div class="row">
                <div class="col-sm-offset-2 col-sm-10">
                	<% if(expIf("hasAuthority('sys:menu:edit')")){ %>
                    <button type="submit" class="btn btn-sm btn-primary">保存提交</button>
                    <% } %>
                    <button type="button" class="btn btn-sm btn-default" onclick="js.closeCurrentTabPage()">关闭窗口</button>
                </div>
            </div>
        </div>
    </#form:form>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == 'true'){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.$('#dataGrid').dataGrid('refreshTreeChildren', $('#parentCode').val(), '${menu.menuCode}');
				});
			}
		}, "json");
    }
});

// 颜色控件初始化
//$('#inputForm .input-color').colorpicker();

// 根据类型显示不同的元素
//$('#menuType input').on('ifCreated ifChecked', function(){
//	if ($(this).is(':checked')){
//		// 1：菜单；2：权限
//		if ($(this).val() == '1'){
//			$('.isPerm').hide();
//			$('.isMenu').show();
//		}else{
//			$('.isMenu').hide();
///			$('.isPerm').show();
//		}
//	}
//});

// 选择上级节点回调方法
function treeselectCallback(id, act, index, layero){
	//if (id == 'parent' && (act == 'ok' || act == 'clear')){
		// 创建并初始化下一个节点信息，如：排序号、默认值
		//$.get('${ctx}/sys/menu/createNextNode?parentCode='
		//		+$('#parentCode').val(), function(data){
			//$('#treeSort').val(data.treeSort);
			//$('#menuType input[value="'+data.menuType+'"]').iCheck('check');
		//});
	//}
}
</script>
</body></html>